package com.darcytech.debezium.core.kafka.connect.model;

import com.darcytech.debezium.core.pool.ConnectorInfo;
import com.fasterxml.jackson.annotation.JsonProperty;

public class Config {

    public Config() {
    }

    public Config(String kafkaServers, String hostName, String port, String userName, String password, String serverId,
                  String group, String dataBases, String tables, String groupSchemaTopic,String connectorName) {
        this.kafkaServers = kafkaServers;
        this.dataBaseHostName = hostName;
        this.dataBasePort = port;
        this.dataBaseUser = userName;
        this.dataBasePassword = password;
        this.dataBaseServerId = serverId;
        this.dataBaseServerName = group;
        this.dataBaseIncludeList = dataBases;
        this.tableIncludeList = tables;
        this.schemaTopic = groupSchemaTopic;
        this.name = connectorName;
        this.connectorClass = "io.debezium.connector.mysql.MySqlConnector";
        this.tasksMax = "1";
        this.includeSchemaChanges = false;
        this.snapshotMode = "schema_only";
        this.snapshotLockingMode = "none";
        this.decimalHandlingMode = "string";
        this.transforms = "unwrap,route";
        this.transformsUnwrapType = "io.debezium.transforms.ExtractNewRecordState";
        this.transformsUnwrapDropTombstones = true;
        this.transformsUnwrapDeleteHandlingMode = "rewrite";
        this.transformsRouteType = "org.apache.kafka.connect.transforms.RegexRouter";
        this.transformsRouteRegex = "([^.]+)\\.([^.]+)\\.([^.]+)";
        this.transformsRouteReplacement = "$1-$3";
        this.converters = "datetime";
        this.datetimeType = "com.darcytech.debezium.converter.MySqlDateTimeConverter";
        this.datetimeFormatDate = "YYYY-MM-dd";
        this.datetimeFormatTime = "HH:mm:ss";
        this.datetimeFormatDatetime = "YYYY-MM-dd HH:mm:ss";
        this.datetimeFormatTimestamp = "YYYY-MM-dd HH:mm:ss";
        this.datetimeFormatTimestampZone = "UTC+8";

    }

    private String name;

    @JsonProperty("connector.class")
    private String connectorClass;

    @JsonProperty("tasks.max")
    private String tasksMax;

    /**
     * {@link ConnectorInfo#hostName}
     */
    @JsonProperty("database.hostname")
    private String dataBaseHostName;

    /**
     * {@link ConnectorInfo#port}
     */
    @JsonProperty("database.port")
    private String dataBasePort;

    /**
     * {@link ConnectorInfo#userName}
     */
    @JsonProperty("database.user")
    private String dataBaseUser;

    /**
     * {@link ConnectorInfo#password}
     */
    @JsonProperty("database.password")
    private String dataBasePassword;

    @JsonProperty("database.server.id")
    private String dataBaseServerId;

    /**
     * {@link ConnectorInfo#group}
     */
    @JsonProperty("database.server.name")
    private String dataBaseServerName;

    /**
     * {@link ConnectorInfo#dataBases}
     */
    @JsonProperty("database.include.list")
    private String dataBaseIncludeList;

    /**
     * {@link ConnectorInfo#tables}
     */
    @JsonProperty("table.include.list")
    private String tableIncludeList;

    @JsonProperty("database.history.kafka.bootstrap.servers")
    private String kafkaServers;

    /**
     * {@link ConnectorInfo#groupSchemaTopic}
     */
    @JsonProperty("database.history.kafka.topic")
    private String schemaTopic;

    @JsonProperty("include.schema.changes")
    private Boolean includeSchemaChanges;

    @JsonProperty("snapshot.mode")
    private String snapshotMode;

    @JsonProperty("snapshot.locking.mode")
    private String snapshotLockingMode;

    @JsonProperty("decimal.handling.mode")
    private String decimalHandlingMode;

    @JsonProperty("transforms")
    private String transforms;

    @JsonProperty("transforms.unwrap.type")
    private String transformsUnwrapType;

    @JsonProperty("transforms.unwrap.drop.tombstones")
    private Boolean transformsUnwrapDropTombstones;

    @JsonProperty("transforms.unwrap.delete.handling.mode")
    private String transformsUnwrapDeleteHandlingMode;

    @JsonProperty("transforms.route.type")
    private String transformsRouteType;

    @JsonProperty("transforms.route.regex")
    private String transformsRouteRegex;

    @JsonProperty("transforms.route.replacement")
    private String transformsRouteReplacement;

    @JsonProperty("converters")
    private String converters;

    @JsonProperty("datetime.type")
    private String datetimeType;

    @JsonProperty("datetime.format.date")
    private String datetimeFormatDate;

    @JsonProperty("datetime.format.time")
    private String datetimeFormatTime;

    @JsonProperty("datetime.format.datetime")
    private String datetimeFormatDatetime;

    @JsonProperty("datetime.format.timestamp")
    private String datetimeFormatTimestamp;

    @JsonProperty("datetime.format.timestamp.zone")
    private String datetimeFormatTimestampZone;

    public String getName() {
        return name;
    }

    public String getConnectorClass() {
        return connectorClass;
    }

    public String getTasksMax() {
        return tasksMax;
    }

    public String getDataBaseHostName() {
        return dataBaseHostName;
    }

    public String getDataBasePort() {
        return dataBasePort;
    }

    public String getDataBaseUser() {
        return dataBaseUser;
    }

    public String getDataBasePassword() {
        return dataBasePassword;
    }

    public String getDataBaseServerId() {
        return dataBaseServerId;
    }

    public String getDataBaseServerName() {
        return dataBaseServerName;
    }

    public String getDataBaseIncludeList() {
        return dataBaseIncludeList;
    }

    public String getTableIncludeList() {
        return tableIncludeList;
    }

    public String getKafkaServers() {
        return kafkaServers;
    }

    public String getSchemaTopic() {
        return schemaTopic;
    }

    public Boolean getIncludeSchemaChanges() {
        return includeSchemaChanges;
    }

    public String getSnapshotMode() {
        return snapshotMode;
    }

    public String getSnapshotLockingMode() {
        return snapshotLockingMode;
    }

    public String getDecimalHandlingMode() {
        return decimalHandlingMode;
    }

    public String getTransforms() {
        return transforms;
    }

    public String getTransformsUnwrapType() {
        return transformsUnwrapType;
    }

    public Boolean getTransformsUnwrapDropTombstones() {
        return transformsUnwrapDropTombstones;
    }

    public String getTransformsUnwrapDeleteHandlingMode() {
        return transformsUnwrapDeleteHandlingMode;
    }

    public String getTransformsRouteType() {
        return transformsRouteType;
    }

    public String getTransformsRouteRegex() {
        return transformsRouteRegex;
    }

    public String getTransformsRouteReplacement() {
        return transformsRouteReplacement;
    }

    public String getConverters() {
        return converters;
    }

    public String getDatetimeType() {
        return datetimeType;
    }

    public String getDatetimeFormatDate() {
        return datetimeFormatDate;
    }

    public String getDatetimeFormatTime() {
        return datetimeFormatTime;
    }

    public String getDatetimeFormatDatetime() {
        return datetimeFormatDatetime;
    }

    public String getDatetimeFormatTimestamp() {
        return datetimeFormatTimestamp;
    }

    public String getDatetimeFormatTimestampZone() {
        return datetimeFormatTimestampZone;
    }

    @Override
    public String toString() {
        return "Config{" +
                "connectorClass='" + connectorClass + '\'' +
                ", tasksMax='" + tasksMax + '\'' +
                ", dataBaseHostName='" + dataBaseHostName + '\'' +
                ", dataBasePort='" + dataBasePort + '\'' +
                ", dataBaseUser='" + dataBaseUser + '\'' +
                ", dataBasePassword='" + dataBasePassword + '\'' +
                ", dataBaseServerId='" + dataBaseServerId + '\'' +
                ", dataBaseServerName='" + dataBaseServerName + '\'' +
                ", dataBaseIncludeList='" + dataBaseIncludeList + '\'' +
                ", tableIncludeList='" + tableIncludeList + '\'' +
                ", kafkaServers='" + kafkaServers + '\'' +
                ", schemaTopic='" + schemaTopic + '\'' +
                ", includeSchemaChanges=" + includeSchemaChanges +
                ", snapshotMode='" + snapshotMode + '\'' +
                ", snapshotLockingMode='" + snapshotLockingMode + '\'' +
                ", decimalHandlingMode='" + decimalHandlingMode + '\'' +
                ", transforms='" + transforms + '\'' +
                ", transformsUnwrapType='" + transformsUnwrapType + '\'' +
                ", transformsUnwrapDropTombstones=" + transformsUnwrapDropTombstones +
                ", transformsUnwrapDeleteHandlingMode='" + transformsUnwrapDeleteHandlingMode + '\'' +
                ", transformsRouteType='" + transformsRouteType + '\'' +
                ", transformsRouteRegex='" + transformsRouteRegex + '\'' +
                ", transformsRouteReplacement='" + transformsRouteReplacement + '\'' +
                ", converters='" + converters + '\'' +
                ", datetimeType='" + datetimeType + '\'' +
                ", datetimeFormatDate='" + datetimeFormatDate + '\'' +
                ", datetimeFormatTime='" + datetimeFormatTime + '\'' +
                ", datetimeFormatDatetime='" + datetimeFormatDatetime + '\'' +
                ", datetimeFormatTimestamp='" + datetimeFormatTimestamp + '\'' +
                ", datetimeFormatTimestampZone='" + datetimeFormatTimestampZone + '\'' +
                '}';
    }
}
